//
//  FirstCell.m
//  Tire
//
//  Created by 王奎卿 on 2017/3/24.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "FirstCell.h"
@interface FirstCell ()

@property (nonatomic,copy) Myblock block;

@end
@implementation FirstCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        CGSize size = [UIScreen mainScreen].bounds.size;
        
        for(int i=0;i<4;i++){
            
            UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
            
            bt.frame =CGRectMake(size.width/4 *i, 0, size.width/4-2, self.frame.size.height);
            bt.tag = 100+i;
            //            [bt setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
            //            [bt setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
            //            [bt setImage:[UIImage imageNamed:@"z2"] forState:UIControlStateNormal];
            [bt setTitle:@"按钮" forState:UIControlStateNormal];
            [bt setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            
            [bt addTarget:self action:@selector(btClick:) forControlEvents:UIControlEventTouchUpInside];
            
            [self.contentView addSubview:bt];
        }
    }
    return self;
}

-(void)btClick:(UIButton *)bt{
    
    if(self.block){
        
        NSLog(@"%@",self.block(bt.tag));
    }
}

-(void)clickBtBlock:(NSString *(^)(NSInteger))block{
    
    if(_block != block){
        
        _block = block;
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
